package com.joplus.housekeeper.bean;

import android.os.Parcel;
import android.os.Parcelable;

import com.hyphenate.chatuidemo.DemoApplication;
import com.joplus.housekeeper.network.RequestHelper;
import com.joplus.housekeeper.utils.StringUtils;

/**
 * Created by bianxiang on 16/5/3.
 */
public class User implements Parcelable {


    /**
     * code : 2000
     * data : {"birthday":-1546329600000,"countrySid":"1","gender":"1","vipWay":"会员劵","openId":null,"memberName":"JO+Essential","vipDeadline":1541483820000,"sid":"acc1466044931968Q8YB","pushId":"85314744366265083838","loginTime":1495690454000,"balance":null,"countryCode":"86","familyName":"ing狗狗","enName":"f\u2006j\u2006f\u2006","addresssCount":2,"email":null,"memberId":"mem1461725756539VxwO","address":null,"registerTime":1466044932000,"nickName":null,"mobile":"18721626075","avatar":"http://joplus-images.oss-cn-shanghai.aliyuncs.com/null?1495690454000","userName":"⑨","isVip":"1","accountId":"acc1466044931968Q8YB","areaId":"area1476075851393EjKc","idcard":null,"name":"uf","expMember":"0","buyType":null,"countryName":"中国","vipDate":1491451276000,"age":null}
     * message :
     */

    private String code;
    /**
     * birthday : -1546329600000
     * countrySid : 1
     * gender : 1
     * vipWay : 会员劵
     * openId : null
     * memberName : JO+Essential
     * vipDeadline : 1541483820000
     * sid : acc1466044931968Q8YB
     * pushId : 85314744366265083838
     * loginTime : 1495690454000
     * balance : null
     * countryCode : 86
     * familyName : ing狗狗
     * enName : f j f
     * addresssCount : 2
     * email : null
     * memberId : mem1461725756539VxwO
     * address : null
     * registerTime : 1466044932000
     * nickName : null
     * mobile : 18721626075
     * avatar : http://joplus-images.oss-cn-shanghai.aliyuncs.com/null?1495690454000
     * userName : ⑨
     * isVip : 1
     * accountId : acc1466044931968Q8YB
     * areaId : area1476075851393EjKc
     * idcard : null
     * name : uf
     * expMember : 0
     * buyType : null
     * countryName : 中国
     * vipDate : 1491451276000
     * age : null
     */

    private DataBean data;
    private String message;

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public DataBean getData() {
        return data;
    }

    public void setData(DataBean data) {
        this.data = data;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public static class DataBean implements Parcelable {
        private String birthday;
        private String countrySid;
        private String gender;
        private String vipWay;
        private String openId;
        private String memberName;
        private String vipDeadline;
        private String sid;
        private String pushId;
        private String loginTime;
        private String balance;
        private String countryCode;
        private String familyName;
        private String enName;
        private int addresssCount;
        private String email;
        private String memberId;
        private String address;
        private String registerTime;
        private String nickName;
        private String mobile;
        private String avatar;
        private String userName;
        private String isVip;
        private String accountId;
        private String areaId;
        private String idcard;
        private String name;
        private String expMember;
        private String buyType;
        private String countryName;
        private String vipDate;
        private String age;
        private String vipExpirDate;

        public String getVipExpirDate() {
            return vipExpirDate;
        }

        public void setVipExpirDate(String vipExpirDate) {
            this.vipExpirDate = vipExpirDate;
        }

        public String getBirthday() {
            return birthday;
        }

        public void setBirthday(String birthday) {
            this.birthday = birthday;
        }

        public String getCountrySid() {
            return countrySid;
        }

        public void setCountrySid(String countrySid) {
            this.countrySid = countrySid;
        }

        public String getGender() {
            return gender;
        }

        public void setGender(String gender) {
            this.gender = gender;
        }

        public String getVipWay() {
            return vipWay;
        }

        public void setVipWay(String vipWay) {
            this.vipWay = vipWay;
        }

        public String getOpenId() {
            return openId;
        }

        public void setOpenId(String openId) {
            this.openId = openId;
        }

        public String getMemberName() {
            return memberName;
        }

        public void setMemberName(String memberName) {
            this.memberName = memberName;
        }

        public String getVipDeadline() {
            return vipDeadline;
        }

        public void setVipDeadline(String vipDeadline) {
            this.vipDeadline = vipDeadline;
        }

        public String getSid() {
            return sid;
        }

        public void setSid(String sid) {
            this.sid = sid;
        }

        public String getPushId() {
            return pushId;
        }

        public void setPushId(String pushId) {
            this.pushId = pushId;
        }

        public String getLoginTime() {
            return loginTime;
        }

        public void setLoginTime(String loginTime) {
            this.loginTime = loginTime;
        }

        public String getBalance() {
            return balance;
        }

        public void setBalance(String balance) {
            this.balance = balance;
        }

        public String getCountryCode() {
            return countryCode;
        }

        public void setCountryCode(String countryCode) {
            this.countryCode = countryCode;
        }

        public String getFamilyName() {
            return familyName;
        }

        public void setFamilyName(String familyName) {
            this.familyName = familyName;
        }

        public String getEnName() {
            return enName;
        }

        public void setEnName(String enName) {
            this.enName = enName;
        }

        public int getAddresssCount() {
            return addresssCount;
        }

        public void setAddresssCount(int addresssCount) {
            this.addresssCount = addresssCount;
        }

        public String getEmail() {
            return email;
        }

        public void setEmail(String email) {
            this.email = email;
        }

        public String getMemberId() {
            return memberId;
        }

        public void setMemberId(String memberId) {
            this.memberId = memberId;
        }

        public String getAddress() {
            return address;
        }

        public void setAddress(String address) {
            this.address = address;
        }

        public String getRegisterTime() {
            return registerTime;
        }

        public void setRegisterTime(String registerTime) {
            this.registerTime = registerTime;
        }

        public Object getNickName() {
            return nickName;
        }

        public void setNickName(String nickName) {
            this.nickName = nickName;
        }

        public String getMobile() {
            return mobile;
        }

        public void setMobile(String mobile) {
            this.mobile = mobile;
        }

        public String getAvatar() {
            return avatar;
        }

        public void setAvatar(String avatar) {
            this.avatar = avatar;
        }

        public String getUserName() {
            return userName;
        }

        public void setUserName(String userName) {
            this.userName = userName;
        }

        public String getIsVip() {
            return isVip;
        }

        public void setIsVip(String isVip) {
            this.isVip = isVip;
        }

        public String getAccountId() {
            return accountId;
        }

        public void setAccountId(String accountId) {
            this.accountId = accountId;
        }

        public String getAreaId() {
            return areaId;
        }

        public void setAreaId(String areaId) {
            this.areaId = areaId;
        }

        public String getIdcard() {
            return idcard;
        }

        public void setIdcard(String idcard) {
            this.idcard = idcard;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getExpMember() {
            return expMember;
        }

        public void setExpMember(String expMember) {
            this.expMember = expMember;
        }

        public Object getBuyType() {
            return buyType;
        }

        public void setBuyType(String buyType) {
            this.buyType = buyType;
        }

        public String getCountryName() {
            return countryName;
        }

        public void setCountryName(String countryName) {
            this.countryName = countryName;
        }

        public String getVipDate() {
            return vipDate;
        }

        public void setVipDate(String vipDate) {
            this.vipDate = vipDate;
        }

        public String getAge() {
            return age;
        }

        public void setAge(String age) {
            this.age = age;
        }

        @Override
        public int describeContents() {
            return 0;
        }

        @Override
        public void writeToParcel(Parcel dest, int flags) {
            dest.writeString(this.birthday);
            dest.writeString(this.countrySid);
            dest.writeString(this.gender);
            dest.writeString(this.vipWay);
            dest.writeString(this.openId);
            dest.writeString(this.memberName);
            dest.writeString(this.vipDeadline);
            dest.writeString(this.sid);
            dest.writeString(this.pushId);
            dest.writeString(this.loginTime);
            dest.writeString(this.balance);
            dest.writeString(this.countryCode);
            dest.writeString(this.familyName);
            dest.writeString(this.enName);
            dest.writeInt(this.addresssCount);
            dest.writeString(this.email);
            dest.writeString(this.memberId);
            dest.writeString(this.address);
            dest.writeString(this.registerTime);
            dest.writeString(this.nickName);
            dest.writeString(this.mobile);
            dest.writeString(this.avatar);
            dest.writeString(this.userName);
            dest.writeString(this.isVip);
            dest.writeString(this.accountId);
            dest.writeString(this.areaId);
            dest.writeString(this.idcard);
            dest.writeString(this.name);
            dest.writeString(this.expMember);
            dest.writeString(this.buyType);
            dest.writeString(this.countryName);
            dest.writeString(this.vipDate);
            dest.writeString(this.age);
            dest.writeString(this.vipExpirDate);
        }

        public DataBean() {
        }

        protected DataBean(Parcel in) {
            this.birthday = in.readString();
            this.countrySid = in.readString();
            this.gender = in.readString();
            this.vipWay = in.readString();
            this.openId = in.readString();
            this.memberName = in.readString();
            this.vipDeadline = in.readString();
            this.sid = in.readString();
            this.pushId = in.readString();
            this.loginTime = in.readString();
            this.balance = in.readString();
            this.countryCode = in.readString();
            this.familyName = in.readString();
            this.enName = in.readString();
            this.addresssCount = in.readInt();
            this.email = in.readString();
            this.memberId = in.readString();
            this.address = in.readString();
            this.registerTime = in.readString();
            this.nickName = in.readString();
            this.mobile = in.readString();
            this.avatar = in.readString();
            this.userName = in.readString();
            this.isVip = in.readString();
            this.accountId = in.readString();
            this.areaId = in.readString();
            this.idcard = in.readString();
            this.name = in.readString();
            this.expMember = in.readString();
            this.buyType = in.readString();
            this.countryName = in.readString();
            this.vipDate = in.readString();
            this.age = in.readString();
            this.vipExpirDate = in.readString();
        }

        public static final Parcelable.Creator<DataBean> CREATOR = new Parcelable.Creator<DataBean>() {
            @Override
            public DataBean createFromParcel(Parcel source) {
                return new DataBean(source);
            }

            @Override
            public DataBean[] newArray(int size) {
                return new DataBean[size];
            }
        };
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.code);
        dest.writeParcelable(this.data, flags);
        dest.writeString(this.message);
    }

    public User() {
    }

    protected User(Parcel in) {
        this.code = in.readString();
        this.data = in.readParcelable(DataBean.class.getClassLoader());
        this.message = in.readString();
    }

    public static final Parcelable.Creator<User> CREATOR = new Parcelable.Creator<User>() {
        @Override
        public User createFromParcel(Parcel source) {
            return new User(source);
        }

        @Override
        public User[] newArray(int size) {
            return new User[size];
        }
    };

    public String getFullName() {
        String firstName = DemoApplication.getInstance().getUser().getData().getFamilyName();
        String lastName = DemoApplication.getInstance().getUser().getData().getName();
        String gen = DemoApplication.getInstance().getUser().getData().getGender();
        String fullName;
        if (StringUtils.isEmpty(gen)) {
            fullName = firstName + (lastName == null ? "" : lastName);
        } else {
            fullName = firstName + (lastName == null ? "" : lastName);
        }

        return fullName;
    }

    public String getChatFullName() {

        String firstName = DemoApplication.getInstance().getUser().getData().getFamilyName();
        String lastName = DemoApplication.getInstance().getUser().getData().getName();
        String gen = DemoApplication.getInstance().getUser().getData().getGender();
        String fullName;
        if (StringUtils.isEmpty(gen)) {
            fullName = firstName + (lastName == null ? "" : lastName);
        } else {
            fullName = firstName + (lastName == null ? "" : lastName) + (gen.equals("1") ? " 先生" : " 女士");
        }

        return fullName;
    }
}
